<template>
	<view class="route-quicksale">
		<view class="cont">
			<view class="inner">
				<view class="have" v-if="goodsList.length">
					<view class="item" v-for="(item,index) in goodsList" :key="index">
						<view class="item-top">

							<view class="top-right">
								<view class="name">
									{{item.title}}
								</view>
								<view class="bot">
									<view class="citem">
										<view class="label">
											收款时间：
										</view>
										<view class="val">
											{{formatTime(item.addtime)}}
										</view>
									</view>

								</view>

							</view>
						</view>
						<view class="pricecont">
							<view class="price">
								+￥{{item.price}}
							</view>
						</view>

					</view>
					<u-loadmore :status="status" />
				</view>
				<view class="none" v-else>
					<u-empty text="暂无记录" mode="list"></u-empty>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	import dayjs from 'dayjs'
	export default {
		data() {
			return {
				userinfo: null,
				status: 'nomore',
				goodsList: [],
				totalPage: 0,
				currentPage: 1
			}
		},
		onShow() {
			if (uni.getStorageSync('uid')) {
				this.userinfo = uni.getStorageSync('userInfo')
				this.getDataList()

			}
		},
		onReachBottom() {

			this.loadData()
		},
		computed: {
			formatTime() {
				return function(val) {
					return dayjs.unix(val).format('YYYY-MM-DD HH:mm:ss')
				}
			}
		},


		methods: {
			getDataList() {
				this.currentPage = 1
				uni.showLoading({
					title: '加载中'
				})
				this.$req.post('/shanghu/shoukuan', {
					shanghuid: this.userinfo.shanghuid || '',
					pageNo: this.currentPage,
					pageSize: 20
				}).then(res => {
					uni.hideLoading()
					let info = res.data
					console.log(info.data, 9999)
					this.goodsList = info.data.data || []
					this.totalPage = info.data.totalPage
					if (this.totalPage <= this.currentPage) {
						this.status = 'nomore'
					}
				})
			},
			loadData() {
				console.log(this.currentPage, this.totalPage)
				if (this.currentPage >= this.totalPage) return;
				this.status = 'loading'
				this.currentPage = ++this.currentPage
				let req = {
					shanghuid: this.userinfo.shanghuid || '',
					pageNo: this.currentPage,
					pageSize: 20
				}
				uni.showLoading({
					title: '加载中'
				})
				this.$req.post('/shanghu/shoukuan', req).then((res) => {
					uni.hideLoading()
					let info = res.data
					this.goodsList = [...this.goodsList, ...info.data.data]

					if (this.currentPage >= this.totalPage) {
						this.status = 'nomore'
					}
				})

			},

		}
	}
</script>

<style lang="scss" scoped>
	.route-quicksale {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 40rpx;



		.cont {
			padding: 30rpx 24rpx 0 24rpx;

			.inner {
				.have {
					.item {
						background-color: #fff;
						padding: 20rpx;
						border-radius: 8rpx;
						margin-bottom: 30rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;

						.item-top {
							display: flex;

							.top-left {
								flex-shrink: 0;
								width: 190rpx;
								height: 190rpx;
								border-radius: 8rpx;
								overflow: hidden;

								.img {
									display: block;
									width: 100%;
									height: 100%;
								}
							}

							.numcont {
								display: flex;
								padding-top: 20rpx;

								.citem {
									display: flex;
									margin-right: 30rpx;
									font-size: 26rpx;

									.label {
										color: #999;
									}
								}
							}

							.top-right {
								flex: 1;
								padding-left: 40rpx;

								.name {
									font-size: 32rpx;
									font-weight: 500;
								}

								.bot {


									.citem {
										display: flex;
										align-items: center;
										font-size: 24rpx;
										margin-top: 20rpx;

										.label {
											color: #999;
										}
									}
								}


							}
						}

						.pricecont {
							.price {
								font-size: 32rpx;

								color: #ED2920;
							}
						}



					}
				}

				.none {
					padding-top: 10vh;
				}
			}
		}

		.footer {
			position: fixed;
			bottom: 0;
			left: 0;
			z-index: 10;
			width: 100%;
			background: #fff;
			padding: 10rpx 20rpx 0 20rpx;
			height: 120rpx;
			box-shadow: 0 0 4px 2px #eeecef;
			box-sizing: border-box;

			.btn {
				width: 100%;
				font-size: 28rpx;
				height: 90rpx;
				border-radius: 20rpx;
				color: #fff;
			}
		}
	}
</style>